package message;



public class head {
	String send;
	String sendTime;
	String to;
	int type;


	@Override
	public String toString() {
		return getSend() + "^" + getTo() + "^" + getType() + "^"
				+ getSendTime() + "$";
	}

	public String getSend() {
		return send;
	}

	public String getSendTime() {
		return sendTime;
	}

	public String getTo() {
		return to;
	}

	public int getType() {
		return type;
	}

	public void setSend(String send) {
		try {
			if (send.length() != 2)
				throw new Exception("send的长度应设置为2");
			else
				this.send = send;
		} catch (Exception e) {
			System.out.println(e);
		}
	}

	public void setSendTime(String sendTime) {
		try {
			if (sendTime.length() != 14)
				throw new Exception("sendTime的长度应设置为14");
			else
				this.sendTime = sendTime;
		} catch (Exception e) {
			System.out.println(e);
		}
	}

	public void setTo(String to) {
		try {
			if (to.length() != 2)
				throw new Exception("to的长度应设置为2");
			else
				this.to = to;
		} catch (Exception e) {
			System.out.println(e);
		}
	}

	public void setType(int type) {
		try {
			if (type < 10 || type > 99)
				throw new Exception("type应设置为10到99之间");
			else
				this.type = type;
		} catch (Exception e) {
			System.out.println(e);
		}
	}

}
